<template>
<div>
      <div>流程信息</div>
      <div>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" >
  <el-form-item label="处理意见" prop="suggestion">
     <el-select v-model="ruleForm.suggestion" placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
  </el-form-item>
  <el-form-item label="意见内容" prop="content" label-width="100px">
    <el-input v-model="ruleForm.content"></el-input>
    </el-form-item>
    <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
    </el-form>
      </div>
<div style="margin-top:25px">
    <el-row >
  <el-col :span="2" :offset="20">  <el-button size="medium" type="success" plain @click="goBack()">返回</el-button></el-col>
</el-row>
   
</div>
</div>
 
</template>

<script>

export default ({
  data(){
    return {
        options: [{
              value: '同意',
          label: '同意'
        }, {
          value: '拒绝',
          label: '拒绝'
        }, 
    
          ],
    ruleForm: {
          suggestion:[],
          content: '',
         
        },
         rules: {
          suggestion: [
            { required: true, message: '请输入意见', trigger: 'blur' },
           
          ],
          content: [
            { required: true, message: '请输入意见内容', trigger: 'blur' }
          ],
          }
    }
  },
  created:function() {
    var bwid = this.$route.query.bwid;
    console.log( this.$route.query.step)
    this.suggestion();
},
   methods:{
       // 重置
         resetForm(formName) {
        this.$refs[formName].resetFields();
      },
    //    提交
      submitForm(formName) {
          console.log(this.$route.query.step)
        this.$refs[formName].validate((valid) => {
          if (valid) {
              //提交更新 历史记录
        this.insert();
          } else {
            this.$message({
                        type: 'warning',
                        message: '请输入内容'
                    });          
            return false;
          }
        });
      },
        goBack() {
        this.$router.push("/home")
        },
      insert() {
         console.log("abc:"+this.ruleForm.suggestion)
          console.log("bwid:"+this.$route.query.bwid)
             this.$axios.post("http://localhost:8082/loan/inserthis", {
               
                     plid: this.$route.query.bwid,
                     step:this.$route.query.step,
                     agent:'张三',
                     suggestion:this.ruleForm.suggestion,
                     content:this.ruleForm.content
            }).then(resp=>{
                console.log(resp.data);
                
            });
      },
      suggestion(){
           this.$axios.get("http://localhost:8082/loan/suggestion", {
               params:{
                        boid: this.$route.query.bwid,
               }
                    
            }).then(resp=>{
                console.log(resp.data);
                if(resp.data.code==200){
                     console.log(resp.data.message);
                    this.ruleForm.content=resp.data.message;
                    
                }else if(resp.data.code==202){
                       console.log(resp.data.message);
                    this.ruleForm.content=resp.data.message;
                }else if(resp.data.code==500){
                     console.log(resp.data.message);
                    this.ruleForm.content=resp.data.message;
                }
            });
      }
  },
  
})
</script>

<style>

      .el-row {
    margin-bottom: 20px;
  
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
